<?php

// test for PHP 5
if(!preg_match('/[56][0-9.]+/', phpversion()))
{
    include('nophp5.php');
    exit();
}

require_once('top.php');

?>
<div id="sidebar1">
    <dl>
        <dt><a href="index.php">Step 1: Upload</a></dt>
        <dd>Upload the Nephtali framework.</dd>
        <dt class="current">Step 2: Configure</dt>
        <dd class="current">Configure your server and Nephtali.</dd>
        <dt><a href="step3.php">Step 3: Test</a></dt>
        <dd>Test the current installation.</dd>
        <dt><a href="step4.php">Step 4: Cleanup</a></dt>
        <dd>Delete the setup directories.</dd>
    </dl>
</div>
<div id="mainContent">
    <h1>Step 2: Configure</h1>
    <p>Now we have to configure PHP, and then configure Nephtali according to the capabilities available on your server.</p>
    <h2>Part A: Configuring PHP</h2>
    <p>PHP can be configured through many different methods, but the most common are through settings in an .htaccess file, or through a php.ini file.</p>
    <p>Below, you can copy the code required for the configuration file that your server utilizes.  	</p>
    <h3>Either, configure with .htaccess</h3>
    <pre><code style="font-size:9px;">
<?php
$revised_include_path = ini_get('include_path').':'.dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'nephtali'.DIRECTORY_SEPARATOR.'src';

$content = <<<EOD

# Make sure you have the editor set up for linux (LF) and not Mac (CR)
# Use php_value for string edits and php_flag for on/off

# Add nephtali/src to the current include path
# You can view the current path by viewing the phpinfo info
# In general, the format should be as below:
# php_value include_path "CURRENT_INCLUDE_PATH:PATH_TO_NEPHTALI_SRC"
php_value include_path "$revised_include_path"

# Set auto_prepend_file to nephtali_x_x_x/src/NCore/Utility/Prepend.php
php_value auto_prepend_file "NCore/Utility/Prepend.php"

# Set auto_append_file to nephtali_x_x_x/src/NCore/Utility/Append.php
php_value auto_append_file "NCore/Utility/Append.php"

# Set display_errors to off
# Can turn on to troubleshoot but don't forget to turn back off
php_flag display_errors off

# Set magic_quotes_gpc to off for security reasons
# https://www2.sans.org/top20/#s1
php_flag magic_quotes_gpc off
php_flag register_globals off

# Only allow cookie-based sessions to avoid session hijacking
# from referrer info
php_flag session.use_only_cookies on

# Set short_open_tag to off so it doesn't interfere with
# xml declarations
php_flag short_open_tag off

EOD;
echo $content;

?>
    </code></pre>
    <p><em>Note: If you're new to .htaccess files and the file disappears when you save it to your local computer, try a quick tutorial on viewing hidden files on <a href="http://www.bleepingcomputer.com/tutorials/tutorial62.html">Windows</a> or <a href="http://guides.macrumors.com/Viewing_hidden_files_on_a_Mac">Mac</a>.</em></p>
    <h3>OR, configure with php.ini</h3>
    <pre><code style="font-size:9px;">
<?php

$revised_include_path = ini_get('include_path').':'.dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'nephtali'.DIRECTORY_SEPARATOR.'src';

$content = <<<EOD

; Make sure you have the editor set up for linux (LF) and not Mac (CR)
; Use the format below for configuring php settings
; setting_name = setting_value (use 'On' or 'Off' for booleans)

; Add nephtali/src to the current include path
; You can view the current path by viewing the phpinfo info
; In general, the format should be as below:
; include_path "CURRENT_INCLUDE_PATH:PATH_TO_NEPHTALI_SRC_DIR"
include_path = "$revised_include_path"

; Set auto_prepend_file to nephtali_x_x_x/src/NCore/Utility/Prepend.php
auto_prepend_file = "NCore/Utility/Prepend.php"

; Set auto_append_file to nephtali_x_x_x/src/NCore/Utility/Append.php
auto_append_file = "NCore/Utility/Append.php"

; Set display_errors to off
; Can turn on long enough to troubleshoot but don't forget to turn back off
display_errors = Off

; Set magic_quotes_gpc to off for security reasons
; https://www2.sans.org/top20/#s1
magic_quotes_gpc = Off
register_globals = Off

; Only allow cookie-based sessions to avoid session hijacking
; from referrer info
session.use_only_cookies = On

; Set short_open_tag to off so it doesn't interfere with
; xml declarations
short_open_tag = Off

EOD;

echo $content;

?>
    </code></pre>
    <h2>Part B: Configuring Nephtali with nconfig.php</h2>
    <ol>
        <li><a href="download.php">Download this nconfig.php file</a></li>
        <li>Save the file to your webserver at the location below:<br />
        <?php echo dirname(dirname(dirname(__FILE__))).'/nephtali/src'; ?>/</li>
    </ol>
    <p><a href="step3.php?name=herbert">Proceed to next step</a></p>
</div>
<?php require_once('bottom.php'); ?>